package android.project;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class SendMessage extends Activity{
	Button btnSendSMS;
	Button btnBackHome; 
	EditText txtPhoneNo;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.message);
        Intent intent = getIntent();
	    final String s = intent.getStringExtra("imageNum");
	    TextView tv=(TextView)findViewById(R.id.msgtext);
	    tv.setText(s);
      
	    btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
        //txtMessage = (EditText) findViewById(R.id.txtMessage);
 
        btnSendSMS.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {                
                String phoneNo = txtPhoneNo.getText().toString();
                //String message = txtMessage.getText().toString();                 
                //String phoneNo = "01022585421";
                String message = s;                 
                
                if (phoneNo.length()>0 && message.length()>0){                
                    sendSMS(phoneNo, message);
                    //---------�̹��� �ٸ� ����� �־����� ���ڴ�. �ڷΰ��⸦ �������� ��� �� ��ΰ� �����ϱ�...;;;//
                    //Intent intent = new Intent(ShareMessage.this, MenuExActivity.class);        		
            		//startActivity(intent); 
            		
                    finish();
                    //finishActivity(this);
            		//this.sleep(5);
            		//SystemClock.sleep(50);
                }else{
                    Toast.makeText(getBaseContext(), "Please enter both phone number and message.", Toast.LENGTH_SHORT).show();
                }
             }

        });
        
        
	}
	private void sendSMS(String phoneNumber, String message)
    {        
        PendingIntent pi = PendingIntent.getActivity(this, 0,
            new Intent(this, SendMessage.class), 0);                
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, pi, null);        
    }

	
}
